import axios from '@/libs/api.request';
import moment from 'moment';

export default {
  provide: {
    beforeDrawerShow: formData => {}
  },

  data() {
    return {
      /** 是否是编辑模式 */
      isEdit: false,
      formItemLayout: {
        labelCol: {
          // xs: { span: 24 },
          // sm: { span: 4 }
        },
        wrapperCol: {
          // xs: { span: 24 },
          // sm: { span: 4 }
        }
      }
    };
  },

  watch: {},

  computed: {},

  beforeCreate() {},

  created() {},

  mounted() {},

  methods: {
    /**
     * 该方法为由树选中后通知的方法
     * @param {*} treeNode 可在界面调用 this.$store.state.treeSelect
     */
    onTreeSelect(treeNode) {
      this.refresh();
    },

    /** 刷新界面 */
    refresh() {
      let crud = this.$refs.crud;
      crud.onRefresh && crud.onRefresh();
    },
    add() {
      let crud = this.$refs.crud;
      crud.onAddBtnClick && crud.onAddBtnClick();
    },
    delete() {
      let crud = this.$refs.crud;
      crud.onDeleteBtnClick && crud.onDeleteBtnClick();
    },

    /** editChange 的监听事件 */
    onEditChange(editVal) {
      this.isEdit = editVal == null ? false : editVal;
    },

    /** 前台向数据模型中添加自定义图标，该方法是从 BaseTreeView 中复制而来，用于树组件 */
    insertIconAndValue(treeNodes) {
      return treeNodes.map(x => {
        // 哟喝，treeSelect好像不支持树下拉的自定义图标显示
        // x.scopedSlots = { icon: 'custom' };
        x.value = x.id;
        return x;
      });
    },

    getValueOfObj(obj) {
      return obj && obj.id + '';
    }
  }
};
